package com.afdor.rws.extension.impl;

import com.afdor.rws.annotation.extension.Extension;
import com.afdor.rws.core.strategy.IdGeneratorStrategy;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author 悭梵
 * @date Created in 2018-09-13 16:36
 */
@Extension(value = "random")
public class RandomIdGeneratorStrategy implements IdGeneratorStrategy<Long> {
    @Override
    public Long generate() {
        return ThreadLocalRandom.current().nextLong(100000000, 999999999999L);
    }

    @Override
    public List<Long> generate(int size) {
        List<Long> idList = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            idList.add(generate());
        }
        return idList;
    }
}
